package com.symaster.pdfcompose.frame.component.tabs;

import com.symaster.pdfcompose.frame.component.menu.TopMenu;

import javax.swing.*;
import java.awt.*;

/**
 * @author yinmiao
 * @version 2023/12/9
 */
public class Tabs extends JComponent {

    private final TopMenu topMenu;
    private final Scrollbar scrollbar;

    public Tabs() {
        this.topMenu = new TopMenu();
        this.scrollbar = new Scrollbar();
        initPage();
    }

    private void initPage() {
        this.setLayout(new BorderLayout());
        this.add(topMenu, BorderLayout.NORTH);
        this.topMenu.setPreferredSize(new Dimension(1, 30));
        this.add(scrollbar, BorderLayout.CENTER);
    }

    public void addTabCard(TabCard tabCard) {
        topMenu.addItem(new TopMenu.Item(tabCard.key(), tabCard.title()));
        scrollbar.add(tabCard.container());
    }

    public TopMenu getTopMenu() {
        return topMenu;
    }

    public Scrollbar getScrollbar() {
        return scrollbar;
    }
}
